package com.longge;

public class IncremovableSubarrayCount {

    public int incremovableSubarrayCount(int[] nums) {

        int ans = 0;
        for (int i = 0; i < nums.length; i++) {
            for (int j = i ; j < nums.length; j++) {
                if (checkInc(nums, i, j)) ans++;
            }
        }
        return ans;
    }

    private boolean checkInc(int[] nums, int i, int j) {
        if (i > 0 && j < nums.length - 1 && nums[i - 1] >= nums[j + 1]) return false;
        for (int k = 0; k < i - 1; k++) {
            if (nums[k] >= nums[k + 1]) return false;
        }

        for (int k = j + 1; k < nums.length - 1; k++) {

            if (nums[k] >= nums[k + 1]) return false;
        }

        return true;

    }

    public static void main(String[] args) {
        int i = new IncremovableSubarrayCount().incremovableSubarrayCount(new int[]{9, 6, 9});
        System.out.println(i);
    }

}
